<?php if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=""){?>
<div class="col-md-8">
<div class="main-content" id="main-content">
	<div class="sub-content">
		<div class="top-header products clearfix">
			<div class="pull-left pad">
				<h1>Users List</h1>
			</div>
			<div class="product-list-details pull-right">				
				<a href="<? echo $this->Url('users')?>/adduser?is_first=1"><input type="button" value="Add user" class="btn"/></a>
			</div>
		</div><br/>
		<div class="product_table table-responsive">
			<table border="1" cellpadding="0" cellspacing="0" width="100%" id="search_results" class="table table-bordered table-hover">
			   <thead>
				<tr class="bg_header">
					<th>SNO</th>
					<th>CompanyName</th>
					<th>Status</th>
					<th>Email</th>
					<th>Phone</th>
					<th>Action</th>
				</tr>
			   </thead>
			</table>
		</div>
	</div>
</div>
</div>
<input type="hidden" id="hid_user_type" name="hid_user_type" value="<? if(isset($_SESSION['user']['user_type']) && $_SESSION['user']['user_type']){echo $_SESSION['user']['user_type'];}?>">
<style>.table td{word-break:break-all;}</style>
<script>
$(function(){
	var userType=$("#hid_user_type").val();
	$.ajax({
		type:	'GET',
		dataType:'json',
		url: BASE_PATH+'/users/alladminusers-ajax?userType='+userType,
		success: function(data){
		eval(data);
		var oTable = $('#search_results').dataTable( {
					aoColumnDefs: [{bSortable: false,
									aTargets: [ 0 ]
									}],
					"bStateSave": true,
					"bAutoWidth": true,
					"sRowSelect": "multi",
					"sPaginationType": "full_numbers",
					"bProcessing": true,
 					"aaData": data,
					"aoColumns": [
						{ "mData": "sno" },
						{ "mData": "companyname" },
						{ "mData": "status" },
						{ "mData": "email" },
						{ "mData": "phone" },
						{ "mData": "action" }
					] 
				});			
		}
	});
});
function deleteUser(user_id){
	if(confirm("Are you sure you want delete record?")){
		window.location=BASE_URL+"/users/delete-users?user_id="+user_id;					
	}
}

</script>
<?php }else{?>
<script>
	window.location='<? echo $this->Url('home')?>';
</script>
<?php }?>